//
//  HNPersonalHomePageViewController.m
//  HappyNews
//
//  Created by baiping on 16/1/12.
//  Copyright © 2016年 BPWBANP. All rights reserved.
//

#import "HNPersonalHomePageViewController.h"
#import <UIButton+WebCache.h>


@interface HNPersonalHomePageViewController ()

@end

@implementation HNPersonalHomePageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    [self setSubviewsContent];

}

- (void)setSubviewsContent{
    
    
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    
    NSString *icon = [defaults valueForKey:@"iconURL"];
    
    NSString *name = [defaults valueForKey:@"name"];
    
    // 设置图片的圆角
    _userIcon.layer.cornerRadius = 40;
    
    _userIcon.layer.masksToBounds = YES;
    
    [_userIcon sd_setBackgroundImageWithURL:[NSURL URLWithString:icon] forState:(UIControlStateNormal)];
    
    _userName.text = name;
    
    [_backBtn setBackgroundImage:[UIImage imageNamed:@"Field_Back"] forState:(UIControlStateNormal)];
    
    
}

- (IBAction)backBtn:(id)sender {
    
    [self dismissViewControllerAnimated:YES completion:nil];
    
    [self.navigationController popViewControllerAnimated:YES];
    
}

- (IBAction)userIconBtn:(id)sender {
    
    
}


- (IBAction)binging:(id)sender {
    
    
}


- (IBAction)outBinging:(id)sender {
    
   
    
    
    
    
    
    
}




- (IBAction)outLogin:(id)sender {
    
    // 清楚用户信息
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    
    [defaults removeObjectForKey:@"name"];
    
    [defaults removeObjectForKey:@"iconURL"];
    
    // 将本页面的用户信息清楚
    
    
    if (_delegate && [_delegate respondsToSelector:@selector(personalHomePageViewControllerRemoveLogin)]) {
        
        [_delegate personalHomePageViewControllerRemoveLogin];
        
    }
    
    // 点击退出后跳转到setting界面 使用转场动画
    //定义个转场动画
    CATransition *animation = [CATransition animation];
    //转场动画持续时间
    animation.duration = 0.5f;
    //计时函数，从头到尾的流畅度
    animation.timingFunction=UIViewAnimationCurveEaseInOut;
    //转场动画类型
    animation.type = kCATransitionFade;
    //转场动画将去的方向
    animation.subtype = kCATransitionFromBottom;
    //动画时你需要的实现
    [self.navigationController.view.layer addAnimation:animation forKey:@"animatiom"];
    
    [self.navigationController popViewControllerAnimated:NO];
    
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
